import { post } from '@/utils/request'

/**
 * 上传文件到 FastDFS
 * @param {File} file - 要上传的文件对象
 * @returns {Promise} 返回文件访问 URL
 */
export function uploadFile(file) {
  const formData = new FormData()
  formData.append('file', file)
  return post('/order/order-client/api/file/upload', formData, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

/**
 * 从 FastDFS 删除文件
 * @param {string} fileUrl - 文件访问 URL
 * @returns {Promise} 返回操作结果
 */
export function deleteFile(fileUrl) {
  const formData = new FormData()
  formData.append('fileUrl', fileUrl)
  return post('/order/order-client/api/file/delete', formData)
}
